<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>角色管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="robots" content="noindex,nofollow" /> 
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/common.css"  media="all">
 

</head>
<body class="page-body">
  <h2 class="comm-title">角色管理</h2>
  <div class="layui-tab">
    <ul class="layui-tab-title page-tab-title">
      <li class="layui-this">管理员管理</li>
      <li><a href="{:url('admin/admin/publish')}">新增管理员</a></li>
    </ul>
  </div> 
  <div class="tpcms-body-div page-main">    
    <form class="layui-form serch new-form" action="{:url('admin/admin/index')}" method="post">
      <div class="layui-form-item" style="float: left;">
        <div class="layui-input-inline">
          <input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="请输入关键词" class="layui-input layui-btn-sm">
        </div>
        <div class="layui-input-inline">
          <div class="layui-inline">
              <select name="admin_cate_id" lay-search="">
                <option value="">角色</option>
                {volist name="$info.cate" id="vo"}
                <option value="{$vo.id}">{$vo.name}</option>
                {/volist}
              </select>
          </div>
        </div>
        <div class="layui-input-inline">
          <div class="layui-inline">
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="create_time2" placeholder="创建时间" name="create_time2">
            </div>
          </div>
        </div>
        <button class="layui-btn layui-btn-danger layui-btn-sm search-btn" lay-submit="" lay-filter="serch">搜索</button>
      </div>
    </form>


    <div class="page-table">
      <table id="demo" lay-filter="test"></table>
    </div>
    
    
    <script type="text/html" id="create_time">
      {{d.create_time}}
    </script>
    <script type="text/html" id="login_time">
      {{d.login_time}}
    </script>
    <script type="text/html" id="barDemo">
      <a href="javascript:;" class="layui-btn layui-btn-xs a_menu layui-btn-primary btn-edit" lay-event="edit">编辑</a>
      <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-primary delete btn-cancel" lay-event="delete">删除</a>
		</script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script src="__PUBLIC__/layui/layui.js"></script>
    
    <script type="text/javascript">
    layui.use('table', function(){
      var table = layui.table,
      form = layui.form;
      table.on('tool(test)', function(obj) {
			// console.log(obj)
			var data = obj.data;
			if(obj.event === 'delete') {
        layer.confirm('确定要删除?', function(index) {
          $.ajax({
            url:"{:url('admin/admin/delete')}",
            data:{id:data.id},
            success:function(res) {
              layer.msg(res.msg);
              if(res.code == 1) {
                layer.msg(res.msg, {
                  offset: '15px',
                  icon: 1,
                  time: 1000
                }, function () {
                  window.location.reload();
                });
              }else{
                layer.msg(res.msg, {
                  offset: '15px',
                  icon: 2,
                  time: 1000
                }, function () {
                  window.location.reload();
                });
              }
            }
          })
        })
			}

      if(obj.event === 'edit') {
				layer.open({
					title: '编辑公司',
					shadeClose: true,
					shade: 0.6,
					skin: "open-layer",
					type: 2,
					area: ['85%', '85%'],
					content: "{:url('publish')}?id=" + data.id
				});
			}

		});
      table.render({
        elem: '#demo'
        ,height: 312
        ,url: "{:url('index_data')}" //数据接口
        ,page: true //开启分页
        ,cols: [[ //表头
          {field: 'id', title: 'ID', width:60}
          ,{field: 'admin_cate_name', title: '角色', width:80}
          ,{field: 'name', title: '用户名', width:80}
          ,{field: 'nickname', title: '昵称', width:80}
          ,{field: 'create_time', title: '创建时间',toolbar: '#create_time', width:100} 
          ,{field: 'login_time', title: '最后登录时间',toolbar: '#login_time', width: 100}
          ,{field: 'login_ip', title: '最后登录IP', width: 80}
          ,{title: '操作', width: 120,toolbar: '#barDemo'}
        ]]






      });
      
    });
    $('.delete').click(function(){
      var id = $(this).attr('id');
      layer.confirm('确定要删除?', function(index) {
        $.ajax({
          url:"{:url('admin/admin/delete')}",
          data:{id:id},
          success:function(res) {
            layer.msg(res.msg);
            if(res.code == 1) {
              setTimeout(function(){
                location.href = res.url;
              },1500)
            }
          }
        })
      })
    })
    $('[name=loupan_edit]').click(function(){
        var url = $(this).data('url');
        layer.open({
          shadeClose: true,
          title:false,
          type:2,
          content:url,
          area: ['95%', '95%'],
        });
        return false;
      })
    </script>
  </div>
</body>
</html>
